

cc.Class({
    extends: cc.Component,

    properties: {
        bg: cc.Node,
        title: cc.Label,
        labelGold: cc.Label,
        clickGold: cc.Button,
    },


    onLoad () {
        this.init(false)
        this.node.zIndex = 3
    },

    init(str){
        this.title.node.active = str
        this.labelGold.node.active = str
        this.clickGold.node.active = str
    },

 
    /**
     * 加载页面顺序
     * @param {*} isSuc flase 死亡结束  true 胜利结束
     */
    over(isSuc){
        game.gameEnd();
        game.jGameLevel.moveIn(isSuc, ()=>{
            this.scheduleOnce(function(){
                this.labelGold.string = utils.goldCrarryBit(data.gold)
                this.gold_top = game.top.getWorldPos()
                this.init(true)
            }.bind(this), 1);
        })
       
       
       
    },


    //获得金币
    getGold(){
        game.createGoldAnim(
            this.node.getPosition(),
            this.gold_top,
            game.top.getMyGoldNode(),
            100,
            20,
            1,
            (gold) => {
              data.addGold(parseInt(data.gold))
              game.playing.init()
              game.top.getMyGold()
              data.init()
              this.init(false)
              game.gameStatus = 0
            }
        );
        cc.audioEngine.resume(game.bgmId)  
        cc.audioEngine.pause(game.jHreoRebirth.hreoDieId)
    }


});
